package GUILayer;

import GUILayer.testSale; // to test sale

/*
 * Main window of 1. semester projekt - datamatiker
 */

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.border.BevelBorder;
import javax.swing.UIManager;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JToolBar;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.event.MenuKeyListener;
import javax.swing.event.MenuKeyEvent;
import javax.swing.border.TitledBorder;
import javax.swing.JTabbedPane;
import java.awt.SystemColor;
import java.awt.Color;
import javax.swing.JLayeredPane;
import javax.swing.JDesktopPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import javax.swing.JTable;
import javax.swing.border.MatteBorder;
import javax.swing.ListSelectionModel;
import javax.swing.border.LineBorder;
import java.awt.Font;
import javax.swing.JSeparator;


public class MainWindow {

	private JFrame frmVestbjergByggecenterAs;
	private JTextField saleFindCustomerText;
	private JTable table;
	private JTable saleAddCustomerTable;
	private JTextField saleFindItemText;
	private JTable saleAddItemTable;
	private JTextField saleAddItemAmountText;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainWindow window = new MainWindow();
					window.frmVestbjergByggecenterAs.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public MainWindow() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmVestbjergByggecenterAs = new JFrame();
		frmVestbjergByggecenterAs.setTitle("Vestbjerg Byggecenter A/S");
		frmVestbjergByggecenterAs.setAlwaysOnTop(true);
		frmVestbjergByggecenterAs.setResizable(false);
		frmVestbjergByggecenterAs.setBounds(100, 100, 800, 600);
		frmVestbjergByggecenterAs.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmVestbjergByggecenterAs.getContentPane().setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(new Color(0, 0, 0)));
		FlowLayout flowLayout = (FlowLayout) panel.getLayout();
		flowLayout.setAlignment(FlowLayout.LEFT);
		flowLayout.setAlignOnBaseline(true);
		frmVestbjergByggecenterAs.getContentPane().add(panel, BorderLayout.SOUTH);
		
		JLabel lblNewLabel = new JLabel("Staturbar");
		panel.add(lblNewLabel);
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setToolTipText("");
		tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
		tabbedPane.setForeground(Color.BLACK);
		frmVestbjergByggecenterAs.getContentPane().add(tabbedPane, BorderLayout.CENTER);
		
		JLayeredPane layeredPane = new JLayeredPane();
		layeredPane.setForeground(Color.LIGHT_GRAY);
		tabbedPane.addTab("Nyt Salg", null, layeredPane, null);
		layeredPane.setLayout(new BorderLayout(0, 0));
		
		JPanel newSalePanel = new JPanel();
		newSalePanel.setToolTipText("");
		layeredPane.add(newSalePanel, BorderLayout.CENTER);
		newSalePanel.setLayout(null);
		
		JPanel saleAddCustomerPanel = new JPanel();
		saleAddCustomerPanel.setLayout(null);
		saleAddCustomerPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Tilf\u00F8je kunde til salget", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		saleAddCustomerPanel.setBounds(10, 11, 356, 221);
		newSalePanel.add(saleAddCustomerPanel);
		
		JButton saleAddCustomerButton = new JButton("Tilf\u00F8j Kunde");
		saleAddCustomerButton.setBounds(232, 191, 111, 23);
		saleAddCustomerPanel.add(saleAddCustomerButton);
		
		JButton SaleFindCustomerButton = new JButton("Find Kunde");
		SaleFindCustomerButton.setBounds(140, 48, 105, 23);
		saleAddCustomerPanel.add(SaleFindCustomerButton);
		
		JLabel saleFindCustomerLabel = new JLabel("Find kunde via ID");
		saleFindCustomerLabel.setBounds(10, 35, 126, 14);
		saleAddCustomerPanel.add(saleFindCustomerLabel);
		
		saleFindCustomerText = new JTextField();
		saleFindCustomerText.setColumns(10);
		saleFindCustomerText.setBounds(10, 49, 120, 20);
		saleAddCustomerPanel.add(saleFindCustomerText);
		
		JButton saleClearCustomerSearchButton = new JButton("Nulstil ");
		saleClearCustomerSearchButton.setBounds(255, 48, 88, 23);
		saleAddCustomerPanel.add(saleClearCustomerSearchButton);
		
		table = new JTable();
		table.setBorder(new LineBorder(new Color(0, 0, 0)));
		table.setBounds(10, 80, 330, 100);
		
		saleAddCustomerPanel.add(table);
		
		JPanel saleActualSalePanel = new JPanel();
		saleActualSalePanel.setLayout(null);
		saleActualSalePanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Salget", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		saleActualSalePanel.setBounds(375, 11, 404, 481);
		newSalePanel.add(saleActualSalePanel);
		
		JLabel label_1 = new JLabel("Kunde");
		label_1.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_1.setBounds(10, 50, 119, 31);
		saleActualSalePanel.add(label_1);
		
		JLabel label_2 = new JLabel("Medarbejder");
		label_2.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_2.setBounds(10, 21, 119, 31);
		saleActualSalePanel.add(label_2);
		
		JLabel label_3 = new JLabel("Tilf\u00F8jede Varer i Salget");
		label_3.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_3.setBounds(10, 81, 384, 22);
		saleActualSalePanel.add(label_3);
		
		JLabel label_4 = new JLabel("Samlet Pris");
		label_4.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_4.setBounds(10, 357, 128, 22);
		saleActualSalePanel.add(label_4);
		
		JLabel label_5 = new JLabel("Kundens Rabat");
		label_5.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_5.setBounds(10, 381, 128, 22);
		saleActualSalePanel.add(label_5);
		
		JLabel lblTotalPris = new JLabel("Total pris");
		lblTotalPris.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblTotalPris.setBounds(10, 404, 128, 22);
		saleActualSalePanel.add(lblTotalPris);
		
		JButton salePaymentButton = new JButton("Betaling");
		salePaymentButton.setBounds(283, 437, 111, 23);
		saleActualSalePanel.add(salePaymentButton);
		
		JButton saleCancelSaleButton = new JButton("Annulere Salget");
		saleCancelSaleButton.setBounds(116, 437, 157, 23);
		saleActualSalePanel.add(saleCancelSaleButton);
		
		JLabel label_7 = new JLabel("0DKR");
		label_7.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_7.setBounds(148, 404, 246, 22);
		saleActualSalePanel.add(label_7);
		
		JLabel label_8 = new JLabel("0%");
		label_8.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_8.setBounds(148, 381, 246, 22);
		saleActualSalePanel.add(label_8);
		
		JLabel label_9 = new JLabel("0DKR");
		label_9.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_9.setBounds(148, 357, 246, 22);
		saleActualSalePanel.add(label_9);
		
		JLabel label_10 = new JLabel("PERSON");
		label_10.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_10.setBounds(139, 50, 119, 31);
		saleActualSalePanel.add(label_10);
		
		JLabel label_11 = new JLabel("ANSAT");
		label_11.setFont(new Font("Tahoma", Font.PLAIN, 18));
		label_11.setBounds(139, 21, 119, 31);
		saleActualSalePanel.add(label_11);
		
		saleAddCustomerTable = new JTable();
		saleAddCustomerTable.setBorder(new LineBorder(new Color(0, 0, 0)));
		saleAddCustomerTable.setBounds(10, 114, 384, 201);
		saleActualSalePanel.add(saleAddCustomerTable);
		
		JButton btnFjernVare = new JButton("Fjern Vare");
		btnFjernVare.setBounds(237, 326, 157, 23);
		saleActualSalePanel.add(btnFjernVare);
		
		JPanel saleAddItemPanel = new JPanel();
		saleAddItemPanel.setLayout(null);
		saleAddItemPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Tilf\u00F8je varer til salget", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		saleAddItemPanel.setBounds(10, 243, 356, 243);
		newSalePanel.add(saleAddItemPanel);
		
		JButton saleAddItemButton = new JButton("Tilf\u00F8j Vare");
		saleAddItemButton.setBounds(229, 209, 111, 23);
		saleAddItemPanel.add(saleAddItemButton);
		
		JLabel saleFindItemLabel = new JLabel("Find Vare via ID");
		saleFindItemLabel.setBounds(10, 29, 124, 14);
		saleAddItemPanel.add(saleFindItemLabel);
		
		saleFindItemText = new JTextField();
		saleFindItemText.setColumns(10);
		saleFindItemText.setBounds(10, 43, 124, 20);
		saleAddItemPanel.add(saleFindItemText);
		
		JButton saleFindItemButton = new JButton("Find Vare");
		saleFindItemButton.setBounds(144, 42, 98, 23);
		saleAddItemPanel.add(saleFindItemButton);
		
		JButton saleClearItemSearchButton = new JButton("Nulstil ");
		saleClearItemSearchButton.setBounds(252, 42, 88, 23);
		saleAddItemPanel.add(saleClearItemSearchButton);
		
		saleAddItemTable = new JTable();
		saleAddItemTable.setBorder(new LineBorder(new Color(0, 0, 0)));
		saleAddItemTable.setBounds(10, 74, 330, 112);
		saleAddItemPanel.add(saleAddItemTable);
		
		saleAddItemAmountText = new JTextField();
		saleAddItemAmountText.setColumns(10);
		saleAddItemAmountText.setBounds(10, 212, 124, 20);
		saleAddItemPanel.add(saleAddItemAmountText);
		
		JLabel saleItemAmountLabel = new JLabel("Antal");
		saleItemAmountLabel.setBounds(10, 198, 124, 14);
		saleAddItemPanel.add(saleItemAmountLabel);
		
		JLayeredPane layeredPane_1 = new JLayeredPane();
		tabbedPane.addTab("Salgshistorik", null, layeredPane_1, null);
		layeredPane_1.setLayout(new BorderLayout(0, 0));
		
		JPanel panel_3 = new JPanel();
		layeredPane_1.add(panel_3, BorderLayout.CENTER);
		
		JLayeredPane layeredPane_2 = new JLayeredPane();
		tabbedPane.addTab("Varer", null, layeredPane_2, null);
		layeredPane_2.setLayout(new BorderLayout(0, 0));
		
		JPanel panel_2 = new JPanel();
		layeredPane_2.add(panel_2, BorderLayout.CENTER);
		
		JLayeredPane layeredPane_3 = new JLayeredPane();
		tabbedPane.addTab("Personer", null, layeredPane_3, null);
		layeredPane_3.setLayout(new BorderLayout(0, 0));
		
		JPanel panel_1 = new JPanel();
		layeredPane_3.add(panel_1, BorderLayout.CENTER);
		
		JMenuBar menuBar = new JMenuBar();
		frmVestbjergByggecenterAs.setJMenuBar(menuBar);
		
		JMenu mnMenu = new JMenu("Menu");
		menuBar.add(mnMenu);
		
		JMenuItem mntmStatistik = new JMenuItem("Statistik");
		mntmStatistik.setEnabled(false);
		mnMenu.add(mntmStatistik);
		
		JSeparator separator = new JSeparator();
		mnMenu.add(separator);
		
		JMenuItem mntmNewMenuItem = new JMenuItem("Afslut Programmet");
		mntmNewMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0); // exit the program
			}
		});
		mnMenu.add(mntmNewMenuItem);
	}
	
	public void fillCustomerTable()
	{
		
		
	}
}
